<?

REQUIRE("../../protect/connect_jeu.php");

$QUERY="SELECT sum(U.batiment_entretient),batiment_user FROM sdbatiment AS B, ubatiment AS U WHERE U.batiment_id=B.batiment_idbatiment  GROUP BY batiment_user";
$resultat=mysql_query($QUERY);

WHILE ($element=mysql_fetch_array($resultat)){


      $query="UPDATE sduser_perso SET perso_lorin=perso_lorin-$element[0] WHERE perso_id=$element[1]";
      $resultat2=mysql_query($query);
      //echo $query."<br>";
}

$QUERY="SELECT sum(U1.unite_nombre*U2.unite_entretient),unite_user FROM sdunite AS U1, uunite AS U2 WHERE U1.unite_unit_id=U2.unite_id  GROUP BY unite_user";
$resultat=mysql_query($QUERY);
WHILE ($element=mysql_fetch_array($resultat)){


      $query="UPDATE sduser_perso SET perso_lorin=perso_lorin-$element[0] WHERE perso_id=$element[1]";
      $resultat2=mysql_query($query);
      //echo $query."<br>";
}


?>
